package cn.lizemin.decorator.version3.flavor;

import cn.lizemin.decorator.version3.drink.Drink;

/**
 * @author lzm
 * @version 1.0
 * @description: TODO
 * @date 2022/4/13 11:18
 */
public class Sugar extends cn.lizemin.decorator.version3.flavor.Flavor {

    /**
     * 子类的构造器
     * @param drink
     */
    public Sugar(Drink drink) {
        this.drink = drink;
    }

    //    public Sugar(Drink drink) {
//        super(drink);
//    }

    @Override
    public String getDescription() {
        return drink.getDescription() + ", 糖";
    }

    @Override
    public double cost() {
        //这里的drink肯定是drink类的某个子类的具体实现，
        // 所以Drink中的该方法只能是使用public修饰，否则我们无法调用其子类的实现
        return drink.cost() + 12;
    }

}
